SET(DEPENDENT_LIBS "")

# Find tetgen
IF (TETGEN_FOUND)
    INCLUDE_DIRECTORIES(${TETGEN_INCLUDE_DIRS})
    LIST(APPEND DEPENDENT_LIBS ${TETGEN_LIBRARIES})
    ADD_DEFINITIONS(-DTETLIBRARY)
ELSE (TETGEN_FOUND)
    MESSAGE(FATAL_ERROR "tetgen is required by tetgen_wrapper and PyTetgen")
ENDIF (TETGEN_FOUND)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

# Enumerate source files
FILE(GLOB_RECURSE SRC_FILES *.cpp)
FILE(GLOB_RECURSE INC_FILES *.h)

ADD_LIBRARY(lib_tetgen_wrapper SHARED ${SRC_FILES} ${INC_FILES})
SET_TARGET_PROPERTIES(lib_tetgen_wrapper PROPERTIES OUTPUT_NAME "tetgen_wrapper")
TARGET_LINK_LIBRARIES(lib_tetgen_wrapper Mesh ${DEPENDENT_LIBS})

ADD_CUSTOM_TARGET(tetgen DEPENDS lib_tetgen_wrapper)
